import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import { Base64 } from 'js-base64'
import './plugins/element.js'
import 'normalize.css'
import './assets/global/global.css'

// 配置base64编解码方法
Vue.prototype.$base64 = Base64

// 配置axios全局信息
axios.defaults.baseURL = '/apis'
axios.defaults.headers.common['X-Token'] = sessionStorage.getItem('X-Token')
Vue.prototype.$axios = axios

// 自动化部署全局组件
const componentContext = require.context('./components', false, /Base[A-Z]\w*.vue$/)

componentContext.keys().forEach((fileName, index, arr) => {
  const componentName = arr[index].slice(2, -4)
  const componentConfig = componentContext(fileName).default
  Vue.component(componentName, componentConfig)
})

Vue.config.productionTip = false

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
